<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags/form" %>

<script type="text/javascript">
    var formId = "lookup";
</script>

<!-- Menu -->
<jsp:include page="menu.jsp"/>

<div class="sub_nav">
    <ul>
        <li>
            <a href="#">
                <img src="<%= request.getContextPath()%>/images/menu/sub_general_on.gif" alt="gernal"/>
            </a>
        </li>
    </ul>
</div>

<!--START: conent -->
<div class="content2">
    <div class="insider">
        <div class="corners">
            <div class="corners_top"></div>
            <div class="column1">
                <table width="360" border="0" cellspacing="4" class="formlayout_table"
                       style="margin-left: auto; margin-right: auto;">

                    <spring:form id="lookup" modelAttribute="lookup" method="post" htmlEscape="true">
                        <input type="hidden" id="submitAction" name="submitAction"/>
                        <input type="hidden" name="lookupType" value="${lookupType}"/>
                        <input type="hidden" id="from" name="from"/>

                        <tr>
                            <th>
                                <label for="User ID">
                                        ${lookupType == 'ProductType' ? 'Product Line' : lookupType} Code:
                                </label>
                            </th>
                            <td>
                                <c:if test="${IS_CREATE}">
                                    <spring:input path="code" cssClass="input1" maxlength="30"/>
                                </c:if>
                                <c:if test="${IS_EDIT}">
                                    ${lookup.code}
                                </c:if>
                            </td>
                        </tr>

                        <tr>
                            <th>
                                <label for="Name">
                                    Name:
                                </label>
                            </th>
                            <td>
                                <spring:input path="name" cssClass="input1" maxlength="255"/>
                            </td>
                        </tr>

                        <tr>
                            <th>
                                <label for="First Name">
                                    Description:
                                </label>
                            </th>
                            <td>
                                <spring:input path="description" cssClass="input1" maxlength="255"/>
                            </td>
                        </tr>

                        <c:if test="${param.lookupType == 'Theme'}">
                            <tr>
                                <th>
                                    <label for="Style Sheet">
                                        Style Sheet:
                                    </label>
                                </th>
                                <td>
                                    <input name="styleSheet" type="text" value="${lookup.styleSheet}" class="input1"/>
                                </td>
                            </tr>
                        </c:if>

                        <tr>
                            <th>
                                <label for="Group">
                                    Group:
                                </label>
                            </th>
                            <td>
                                <select name="userGroup.name" class="select1">
                                    <c:forEach var="group" items="${groups}">
                                        <option value="${group.name}" ${group.name eq lookup.userGroup.name ? 'selected' : ''}>
                                                ${group.name}
                                        </option>
                                    </c:forEach>
                                </select>
                            </td>
                        </tr>
                    </spring:form>
                    <tr>
                        <th>
                            <label for="Last Modified Date">
                                Last Modified Date:
                            </label>
                        </th>
                        <td>
                            <fmt:formatDate value="${lookup.modifiedOn}" pattern="dd-MMM-yyyy"/>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <label for="Last Modified By">
                                Last Modified By:
                            </label>
                        </th>
                        <td>
                            ${lookup.modifiedBy.username}
                        </td>
                    </tr>
                </table>
            </div>

            <!-- Function Begin -->
            <script type="text/javascript">
                function createAction(submitAction) {
                    Dialogs.saveTargetValue();
                    afterSubmitRedirect(formId, "create.html", submitAction, "submitAction");
                }

                function editAction(submitAction) {
                    Dialogs.saveTargetValue();
                    afterSubmitRedirect(formId, "edit.html", submitAction, "submitAction");
                }
            </script>

            <ul class="functions1">
                <li>
                    <a href="#" onclick="${OPERATION}Action('submit');">
                        <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_save.gif" class="btn"/>
                    </a>
                </li>
                <li>
                    <a href="#" onclick="${OPERATION}Action('submit_and_exit');">
                        <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_save_exit.gif" class="btn"/>
                    </a>
                </li>
                <li>
                    <a href="#" onclick="${OPERATION}Action('SUBMIT_AND_NEW');">
                        <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_save_create_new.gif"
                             class="btn"/>
                    </a>
                </li>
                <li>
                    <a href="#"
                       onclick="Dialogs.unescapedLink('cancel.html?lookupType=${param.lookupType}', 'from')">
                        <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_cancel.gif" class="btn"/>
                    </a>
                </li>
            </ul>
            <!-- Function End -->

            <div class="corners_bottom"></div>
        </div>

        <div class="message">
            ${message}
            ${empty message ? "" : "<br />"}

            <div style="color:red">
                ${errors['code.errors'][0]}
                ${empty errors['code.errors'][0] ? "" : "<br />"}
                ${errors['name.errors'][0]}
                ${empty errors['name.errors'][0] ? "" : "<br />"}
                ${errors['description.errors'][0]}
                ${empty errors['description.errors'][0] ? "" : "<br />"}
            </div>
        </div>
    </div>
</div>
<!--END: conent -->